//
//  AppDelegate.m
//  1.28 十二期微博
//
//  Created by mac on 15/1/28.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "AppDelegate.h"
#import "LWTabBarController.h"
#import "LWAccount.h"
#import "LWNewfeatureVc.h"
#import "LWWelcomeVc.h"
#import "UIWindow+Extension.h"
@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // 0. 请求用户授权
    if ([UIDevice currentDevice].systemVersion.doubleValue >= 8.0) {
        
        UIUserNotificationType type = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
        UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:type categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
    }

    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    [self.window makeKeyAndVisible];
    LWAccount *account = [LWAccount accountFromSandBox];
    if (account != nil) {
        [self.window chooseViewController];
    }else{
    LWTabBarController *tabbarVc = [[LWTabBarController alloc] init];
    self.window.rootViewController = tabbarVc;    
    }
    
    return YES;
}
- (void)applicationDidEnterBackground:(UIApplication *)application{

    [application beginBackgroundTaskWithExpirationHandler:nil];
}

@end
